package com.test.thrift.util;

import com.google.gson.Gson;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * Created by MAC on 2018/10/23.
 */
public class JsonUtil {
    public static String ListToJson(Collection collection) {
        if (collection != null) {
            Gson gson = new Gson();
            return gson.toJson(collection);
        }
        return null;
    }

    public static List<String> ListToJsonList(Collection collection) {
        if (collection != null) {
            List<String> list = new LinkedList<String>();
            for (Object obj : collection) {
                Gson gson = new Gson();
                list.add(gson.toJson(collection));
            }
            return list;
        }
        return null;
    }
}
